package 抽象类作业;

public class Animal {
    public static void main(String[] args) {

        Cat cat = new Cat();
        cat.setAge(5);
        cat.setName("猫");
        cat.voice();
        cat.eat();

        Dog dog = new Dog();
        dog.setAge(10);
        dog.setName("狗");
        dog.eat();
        dog.voice();
    }




    //定义变量：名称
    private String name;
    //定义变量：年龄
    private  int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
class Cat extends Animal{
    public  void  voice(){
            String name = getName();
        System.out.println("我是"+name+"，我会喵喵叫");
    }
    public  void  eat(){
        int age = getAge();
        System.out.println("我是"+age+"岁了");
    }
}
class  Dog extends Animal{
    public  void  voice(){
        System.out.println("我是"+getName()+"我会汪汪叫");
    }
    public  void  eat(){
        System.out.println("我是"+getAge()+"我要吃狗粮");
    }
}

